﻿using System;

namespace ThresholdAssistant.NLogSdk
{
    /// <summary>
    /// 日志管理基础常量配置
    /// </summary>
    static class NLogConst
    {
        /// <summary>
        /// 烈性
        /// </summary>
        internal const string LoggerKeyType = "Type";

        /// <summary>
        /// 接口地址
        /// </summary>
        internal const string LoggerKeyUrl = "RequestUrl";

        /// <summary>
        /// 
        /// </summary>
        internal const string GlobalLoggerName = "GlobalJson";

        /// <summary>
        /// 请求Id
        /// </summary>
        internal const string UniqueId = "UniqueId";

        /// <summary>
        /// 时间
        /// </summary>
        internal const string LoggerKeyTotalSeconds = "TotalSeconds";

        /// <summary>
        /// 内容长度
        /// </summary>
        internal const string LoggerKeyContentLength = "ContentLength";

        /// <summary>
        /// 商家编号
        /// </summary>
        internal const string MerchantNo = "MerchantNo";

        /// <summary>
        /// 操作编号
        /// </summary>
        internal const string SerialNo = "SerialNo";

        /// <summary>
        /// 机器人编号
        /// </summary>
        internal const string RobotSerialNo = "RobotSerialNo";

        /// <summary>
        /// 请求头
        /// </summary>
        internal const string Headers = "Headers";

        /// <summary>
        /// 请求参数
        /// </summary>
        internal const string Request = "Request";

        /// <summary>
        /// 响应结果
        /// </summary>
        internal const string Response = "Response";

        /// <summary>
        /// 时间格式化,false = 精确到毫秒。
        /// </summary>
        /// <param name="content"></param>
        /// <param name="toMillisecond"></param>
        /// <returns></returns>
        public static string ToTimeFormat(this DateTime content, bool toMillisecond)
        {
            if (content != null)
            {
                if (!toMillisecond)
                {
                    return content.ToString("yyyy-MM-dd HH:mm:ss.fff");
                }
                else
                {
                    return content.ToString("yyyy-MM-dd HH:mm:ss");
                }
            }
            return string.Empty;
        }
    }
}